package mx.com.mindbits.bandpay.utils;

import mx.com.mindbits.bandpay.R;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

public class GenericAlert {
	
	public static AlertDialog.Builder generateAlertDialog(String titulo, String mensaje, Context contexto){
		LayoutInflater personalInflater = (LayoutInflater)contexto.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View viewDialog = personalInflater.inflate(R.layout.custom_alert_dialog, null);
		
		TextView  tituloDialogo      = (TextView)viewDialog.findViewById(R.id.titleAlertTextNormal);
		TextView  mensajeDialogo     = (TextView)viewDialog.findViewById(R.id.messageTextNormal);
		
		tituloDialogo.setText(titulo);
		mensajeDialogo.setText(mensaje);
		
		AlertDialog.Builder dialogoAlerta = new AlertDialog.Builder(contexto);
		dialogoAlerta.create();		
		
		dialogoAlerta.setPositiveButton(android.R.string.ok, new OnClickListener(){

			@Override
			public void onClick(DialogInterface arg0, int arg1) { 
				
			}});
		
		dialogoAlerta.setView(viewDialog);
		
		return dialogoAlerta;		
	}
	
	
	
	
	public static AlertDialog.Builder generateInformativeDialog(String titulo, String mensaje, int cvvSombra, Context contexto){
		LayoutInflater personalInflater = (LayoutInflater)contexto.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View viewDialog = personalInflater.inflate(R.layout.custom_alert_dialog_image, null);
		
		ImageView imageDialog = (ImageView)viewDialog.findViewById(R.id.imageDialog1);
		TextView  tituloDialogo      = (TextView)viewDialog.findViewById(R.id.titleAlertText);
		TextView  mensajeDialogo     = (TextView)viewDialog.findViewById(R.id.messageText);
		
		tituloDialogo.setText(titulo);
		mensajeDialogo.setText(mensaje);
		
		imageDialog.setImageResource(cvvSombra);
		
		AlertDialog.Builder dialogoAlerta = new AlertDialog.Builder(contexto);
		dialogoAlerta.create();		
		
		dialogoAlerta.setPositiveButton(android.R.string.ok, new OnClickListener(){

			@Override
			public void onClick(DialogInterface arg0, int arg1) { 
				
			}});
		
		dialogoAlerta.setView(viewDialog);
		return dialogoAlerta;		
	}
	
	public static AlertDialog.Builder generateAlertDWiFi(String titulo, String mensaje, Context contexto){
		final Context _contexto = contexto;
		
		LayoutInflater personalInflater = (LayoutInflater)contexto.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View viewDialog = personalInflater.inflate(R.layout.custom_alert_dialog, null);
		
		TextView  tituloDialogo      = (TextView)viewDialog.findViewById(R.id.titleAlertTextNormal);
		TextView  mensajeDialogo     = (TextView)viewDialog.findViewById(R.id.messageTextNormal);
		
		tituloDialogo.setText(titulo);
		mensajeDialogo.setText(mensaje);
		
		AlertDialog.Builder dialogoAlerta = new AlertDialog.Builder(contexto);
		dialogoAlerta.create();		
		
		dialogoAlerta.setPositiveButton(android.R.string.ok, new OnClickListener(){

			@Override
			public void onClick(DialogInterface arg0, int arg1) { 
				_contexto.startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS));
			}});
				
		dialogoAlerta.setView(viewDialog);
		
		return dialogoAlerta;		
	}
	
	public static AlertDialog.Builder generateAlertWithIntent(String titulo, String mensaje,
			Intent intent, Context contexto){
		final Context _contexto = contexto;
		final Intent _intent = intent;
		
		LayoutInflater personalInflater = (LayoutInflater)contexto.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View viewDialog = personalInflater.inflate(R.layout.custom_alert_dialog, null);
		
		TextView  tituloDialogo      = (TextView)viewDialog.findViewById(R.id.titleAlertTextNormal);
		TextView  mensajeDialogo     = (TextView)viewDialog.findViewById(R.id.messageTextNormal);
		
		tituloDialogo.setText(titulo);
		mensajeDialogo.setText(mensaje);
		
		AlertDialog.Builder dialogoAlerta = new AlertDialog.Builder(contexto);
		dialogoAlerta.create();		
		
		dialogoAlerta.setPositiveButton(android.R.string.ok, new OnClickListener(){

			@Override
			public void onClick(DialogInterface arg0, int arg1) { 
				_contexto.startActivity(new Intent(_intent));
			}});
				
		dialogoAlerta.setView(viewDialog);
		
		return dialogoAlerta;		
	}
	
	
}
